<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Pending cluster tasks API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'cluster-pending.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/cluster-pending.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/cluster-pending.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/cluster-pending.html" rel="nofollow" target="_blank">../en/cluster-pending.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="cluster.html">Cluster APIs</a></span>
»
<span class="breadcrumb-node">Pending cluster tasks API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="cluster-nodes-stats.html">« Nodes stats API</a>
</span>
<span class="next">
<a href="cluster-remote-info.html">Remote cluster info API »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="cluster-pending"></a>Pending cluster tasks API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cluster/pending.asciidoc">edit</a>
</h2>
</div></div></div>

<p>Returns cluster-level changes that have not yet been executed.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="cluster-pending-api-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cluster/pending.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">GET /_cluster/pending_tasks</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="cluster-pending-api-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cluster/pending.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The pending cluster tasks API returns a list of any cluster-level changes (e.g.
create index, update mapping, allocate or fail shard) which have not yet been
executed.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>This API returns a list of any pending updates to the cluster state. These are distinct from the tasks reported by the
<a class="xref" href="tasks.html" title="Task management API">Task Management API</a> which include periodic tasks and tasks initiated by the user, such as node stats, search queries, or create
index requests. However, if a user-initiated task such as a create index command causes a cluster state update, the activity of this task
might be reported by both task api and pending cluster tasks API.</p>
</div>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="cluster-pending-api-path-params"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cluster/pending.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">local</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, the request retrieves information from the local
node only. Defaults to <code class="literal">false</code>, which means information is retrieved from
the master node.
</dd>
<dt>
<span class="term">
<code class="literal">master_timeout</code>
</span>
</dt>
<dd>
(Optional, <a class="xref" href="common-options.html#time-units" title="Time units">time units</a>) Specifies the period of time to wait for
a connection to the master node. If no response is received before the timeout
expires, the request fails and returns an error. Defaults to <code class="literal">30s</code>.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="cluster-pending-api-response-body"></a>Response body<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cluster/pending.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">tasks</code>
</span>
</dt>
<dd>
(object) A list of pending tasks.
</dd>
<dt>
<span class="term">
<code class="literal">insert_order</code>
</span>
</dt>
<dd>
(integer) The number that represents when the task has been inserted into
the task queue.
</dd>
<dt>
<span class="term">
<code class="literal">priority</code>
</span>
</dt>
<dd>
(string) The priority of the pending task.
</dd>
<dt>
<span class="term">
<code class="literal">source</code>
</span>
</dt>
<dd>
(string) A general description of the cluster task that may include a reason
and origin.
</dd>
<dt>
<span class="term">
<code class="literal">time_in_queue_millis</code>
</span>
</dt>
<dd>
(integer) The time expressed in milliseconds since the task is waiting for
being performed.
</dd>
<dt>
<span class="term">
<code class="literal">time_in_queue</code>
</span>
</dt>
<dd>
(string) The time since the task is waiting for being performed.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="cluster-pending-api-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cluster/pending.asciidoc">edit</a>
</h3>
</div></div></div>
<p>Usually the request will return an empty list as cluster-level changes are fast.
However, if there are tasks queued up, the response will look similar like this:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">{
   "tasks": [
      {
         "insert_order": 101,
         "priority": "URGENT",
         "source": "create-index [foo_9], cause [api]",
         "time_in_queue_millis": 86,
         "time_in_queue": "86ms"
      },
      {
         "insert_order": 46,
         "priority": "HIGH",
         "source": "shard-started ([foo_2][1], node[tMTocMvQQgGCkj7QDHl3OA], [P], s[INITIALIZING]), reason [after recovery from shard_store]",
         "time_in_queue_millis": 842,
         "time_in_queue": "842ms"
      },
      {
         "insert_order": 45,
         "priority": "HIGH",
         "source": "shard-started ([foo_2][0], node[tMTocMvQQgGCkj7QDHl3OA], [P], s[INITIALIZING]), reason [after recovery from shard_store]",
         "time_in_queue_millis": 858,
         "time_in_queue": "858ms"
      }
  ]
}</pre>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="cluster-nodes-stats.html">« Nodes stats API</a>
</span>
<span class="next">
<a href="cluster-remote-info.html">Remote cluster info API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>